From: Simon McVittie Date: Sun, 30 Oct 2016 14:14:09 +0000 (+0000) Subject: ostree_admin_option_context_parse: explicitly clean up when exiting early X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~44^2~20 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22%22?a=commitdiff_plain;h=4c32344b8e71e40034fcdbf3053f46c290fac785;p=ostree.git ostree_admin_option_context_parse: explicitly clean up when exiting early The cleanup attribute doesn't clean up before calling a noreturn function like exit(). Explicitly clean up the pointer variables (but don't assume that a simple g_object_unref() would be OK either, in case the behaviour of the cleanup attribute changes). This isn't a real leak since we're about to exit anyway, but if we don't fix it then valgrind memcheck will make the tests fail. Signed-off-by: Simon McVittie Closes: #559 Approved by: cgwalters --- diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index 18c13239..5080e8c6 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -366,6 +366,13 @@ ostree_admin_option_context_parse (GOptionContext *context, g_print ("%s\n", deployment_path); + /* The g_autoptr, g_autofree etc. don't happen when we explicitly + * exit, making valgrind complain about leaks */ + g_clear_object (&sysroot); + g_clear_object (&sysroot_path); + g_clear_object (&deployment_file); + g_clear_pointer (&deployments, g_ptr_array_unref); + g_clear_pointer (&deployment_path, g_free); exit (EXIT_SUCCESS); }